#ifndef METHODEDITOR_H
#define METHODEDITOR_H

#include <QDialog>
#include <QDebug>

#include "uml/class/classmethod.h"
#include "uml/datatypedictionary.h"
#include "gui/editors/highlighters/umlmethodhighlighter.h"

class ClassMethod;
class UmlClassItem;

namespace Ui {
    class MethodEditor;
}

class MethodEditor : public QDialog {
    Q_OBJECT
public:
    MethodEditor(UmlClassItem *classItem, ClassMethod *classMethod = 0);
    ~MethodEditor();

    void setMeth(ClassMethod *meth);
    void setClassItem(UmlClassItem *classItem);
    void setDatatypes(DatatypeDictionary *datatypes);

protected:
    void changeEvent(QEvent *e);

    UmlMethodHighlighter *_previewHighlighter;

private:
    Ui::MethodEditor *ui;

    ClassMethod *_meth;
    UmlClassItem *_classItem;
    DatatypeDictionary *_datatypes;

    QModelIndex _selectedIndex;

private slots:
    void save();
    void cancel();
    void setName(QString name);
    void setVisibility(int index);
    void setReturnType(QString type);
    void setIsAbstract(bool isAbstract);
    void addArg();
    void removeArg();
    void moveArgUp();
    void moveArgDown();
    void updatePreview();
};

#endif // METHODEDITOR_H
